package com.yiqi.liebang.feature.order.model;

import com.luck.picture.lib.rxbus2.RxBus;
import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.yiqi.liebang.entity.bo.AnswerBo;
import com.yiqi.liebang.entity.bo.CommentBo;
import com.yiqi.liebang.entity.bo.OrderBo;
import com.yiqi.liebang.entity.bo.OrderQuestionInfofBo;
import com.yiqi.liebang.entity.bo.PageBo;
import com.yiqi.liebang.entity.bo.QuestionDetailBo;
import com.yiqi.liebang.feature.order.contract.OrderContract;
import com.yiqi.liebang.feature.order.contract.QuestionInfoContract;
import com.yiqi.liebang.feature.order.dependencies.order.DaggerOrderModelComponent;
import com.yiqi.liebang.feature.order.dependencies.questionInfo.DaggerQuestionInfoModelComponent;
import com.yiqi.liebang.framework.api.ApiLib;
import com.yiqi.liebang.framework.api.HomeApi;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;

public class QuestionInfoModel implements QuestionInfoContract.Model {

    @Inject
    HomeApi api;


    @Inject
    public QuestionInfoModel() {
        DaggerQuestionInfoModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<OrderQuestionInfofBo> getOrderQuestionInfo(String id,int type) {
        return api.getOrderInfo(id,type).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> refusedQuestion(String id) {
        return api.toRefused(id).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> toAnswer(AnswerBo answerBo) {
        return api.toAnswerQuestion(answerBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> toAnswer(CommentBo answerBo) {
        return api.toCommentQuestion(answerBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<QuestionDetailBo> getOrderQuestionDetail(CommentBo id) {
        return api.getQuestionDetail(id).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> toCommentQuestion(CommentBo answerBo) {
        return api.toCommentQuestionInfo(answerBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}
